﻿/**
 * ...
 * @author George Mavchun
 */

package gui.hug.priv;
import gui.hug.HUGButton;
import gui.hug.HUGColors;

class HUGTabButton extends HUGButton
{
	private var activeTabDisplayState : HUGTabButtonDisplayState;
	
	private var tabDisplayState : HUGTabButtonDisplayState;
	private var tabOverDisplayState : HUGTabButtonDisplayState;
	
	private var active : Bool;

	public function new(text : String, _active : Bool) 
	{
		super(text);
		
		active = _active;
		
		activeTabDisplayState = new HUGTabButtonDisplayState("<font size='12' color='#FFFFFF' face='Arial'>" + text + "</font>", HUGColors.VK_BUTTON);
		
		tabDisplayState = new HUGTabButtonDisplayState("<font size='12' color='#36638E' face='Arial'>" + text + "</font>", HUGColors.VK_BACKGROUND);
		tabOverDisplayState = new HUGTabButtonDisplayState("<font size='12' color='#36638E' face='Arial'>" + text + "</font>", HUGColors.VK_BORDER_INNER); // todo
		
		setStates();
	}
	
	private function setStates() {
		downState = active ? activeTabDisplayState : tabOverDisplayState;
		overState = active ? activeTabDisplayState : tabOverDisplayState;
		upState = active ? activeTabDisplayState : tabDisplayState;
		hitTestState = active ? activeTabDisplayState : tabDisplayState;
	}
	
	public function changeState() {
		active = !active;
		setStates();
	}
	
	public function setState(state : Bool) {
		active = state;
		setStates();
	}
	
	public function getFactWidth() : Float {
		return tabDisplayState.getFactWidth();
	}
}